package org.lanqiao.common;


/**
 * 基于ThreadLocal封装的工具类，获取和设置当前登录用户的id
 */
public class ThreadLocalHandler {
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    /**
     * 获取当前登录用户id，放入threadLocal中
     * @param id
     */
    public static void setCurrentId(Long id){
         threadLocal.set(id);
    }


    /**
     * 从threadLocal中获取当前登录用户id
     * @return
     */
    public static Long getCurrentId(){
        return threadLocal.get();
    }
}
